#include "mainWindow.h"

mainWindow::mainWindow()
{	
	setWindowTitle("hehe");
	textEdit = new QTextEdit();
	setCentralWidget(textEdit);

	createActions();
	createMenus();
	createToolBar();
	createStatusBar();
	createDockWindow();
}

void mainWindow::createActions()
{
	openAction = new QAction(QIcon(":/images/open.png"), tr("打开"), this);
//	openAction->setShortcuts(QKeySequence::New);
//	openAction->setShortcut(QKeySequence(tr("ctrl+o")));
	openAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
	openAction->setStatusTip(tr("打开一个文件"));
	connect(openAction, SIGNAL(triggered()),this, SLOT(openSlot()));
}
void mainWindow::createMenus()
{
	fileMenu = menuBar()->addMenu(tr("&文件"));
	fileMenu->addAction(openAction);
}
void mainWindow::createToolBar()
{
	fileToolBar = addToolBar(tr("文件"));
	fileToolBar->addAction(openAction);
}
void mainWindow::createStatusBar()
{
	statusBar()->showMessage(tr("准备"));
}

void mainWindow::createDockWindow()
{
	QDockWidget *dock = new QDockWidget(tr("dock"), this);
	text = new QTextEdit();
	dock->setWidget(text);
	addDockWidget(Qt::LeftDockWidgetArea, dock);
}

void mainWindow::openSlot()
{
	QMessageBox::aboutQt(this, "haha");
}
void mainWindow::saveSlot()
{

}
void mainWindow::saveAsSlot()
{

}
void mainWindow::exitSlot()
{

}
void mainWindow::aboutSlot()
{

}
